package com.yzy.fly.mapper;

import com.yzy.fly.entity.role.FlyService;
import com.yzy.fly.kernel.mapper.FlyBasicMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;


@Mapper
public interface FlyServiceMapper extends FlyBasicMapper<FlyService> {

    @Select("select * from fly_service a where 1=1")
    List<FlyService> selectAll();

    @Select("select * from fly_service a where 1=1 and a.componentId = #{componentId} order by seq asc")
    List<FlyService> selectAllByComponentId(@Param("componentId") int componentId);


    @Select("select * from fly_service a where 1=1 and a.systemId = #{systemId}")
    List<FlyService> selectAllBySystemId(@Param("systemId") int systemId);

    @Select("select * from fly_service a where 1=1 and a.parentId = #{controllerId}")
    List<FlyService> selectAllByControllerId(@Param("controllerId") int controllerId);

    @Select("select * from fly_service a where 1=1 and a.name = #{name}")
    FlyService selectOneByName(@Param("name") String name);

    /**
     * 批量插入（mysql）
     * @param entityList
     * @return
     */
    Integer insertBatchSomeColumn(Collection<FlyService> entityList);

    @Select("select * from fly_service a where systemId = #{systemId} order by a.packageName asc")
    List<FlyService> selectAllPackageNameAsc(@Param("systemId") Integer systemId);

}